// Escape HTML method
function HTMLEscape(str) {
  return str.replace(/<|>|&|"/g, (match) => {
    switch (match) {
      case "<":
        return "&lt;";
      case ">":
        return "&gt;";
      case "&":
        return "&amp;";
      case '"':
        return "&quot;";
    }
  });
}

// UNEscape HTML method
function HTMLUNEscape(str) {
  return str.replace(/&gt;|&lt;|&amp;|&quot;/g, (match) => {
    switch (match) {
      case "&gt;":
        return ">";
      case "&lt;":
        return "<";
      case "&amp;":
        return "&";
      case "&quot;":
        return '"';
    }
  });
}

module.exports = {
  HTMLEscape,
  HTMLUNEscape,
};
